<template>
  <t-menu-item v-bind="linkProps()">
    <template #icon>
      <slot name="icon" />
    </template>
    <template #content>
      <slot name="content" />
    </template>
    <template #default>
      <slot />
    </template>
  </t-menu-item>
</template>

<script setup lang="ts">
import { isExternal } from '@/utils/is.js';
interface IProps {
  to: string | any;
  value: any;
}
const props = withDefaults(defineProps<IProps>(), {});

const _isExternal = computed(() => {
  return isExternal(props.to);
});
const linkProps = () => {
  if (_isExternal.value) {
    return {
      value: props.value,
      href: props.to,
      target: '_blank',
    };
  }
  return {
    value: props.value,
    to: props.to,
  };
};
</script>
